/*! \file   inheritancenode.h
	\author HiddenSeeker\
	Defines a node, that describes an inheritance
*/
#include "classtype.h"
#include "renamenode.h"
#include "identifierstring.h"
#include <stdio.h>
#pragma once


/*! Declares an inheritance node - node that describes inheritance parameters
*/
class InheritanceNode: public AbstractNode
{
 private:
		 ClassTypeNode * m_classname;
		 ListNode<IdentifierNode> * m_undefines;
		 ListNode<IdentifierNode> * m_redefines;
		 ListNode<RenameNode>     * m_renames;
		 ListNode<IdentifierNode> * m_selects;
 public:
		 inline unsigned int redefinesCount() const { if (!m_redefines) return 0; return m_redefines->vector().size(); }
		 inline const std::string & redefine(unsigned int i)
		 {
			return m_redefines->vector()[i]->data();
		 }
		 inline unsigned int renameCount() const { if (!m_renames) return 0; return m_renames->vector().size(); }
		 inline const std::string & renameOldName(unsigned int i)
		 {
			 return m_renames->vector()[i]->from();
		 }
		 inline const std::string & renameNewName(unsigned int i)
		 {
			 return m_renames->vector()[i]->to();
		 }
		 inline std::string*  renameAlias(unsigned int i)
		 {
			 return m_renames->vector()[i]->alias();
		 }

	     inline ClassTypeNode *  className() const            { return m_classname;}
		 inline ListNode<IdentifierNode> * undefines() const { return m_undefines; }
		 inline ListNode<IdentifierNode> * redefines() const { return m_redefines; }
		 inline ListNode<IdentifierNode> * selects() const { return m_selects; }
		 inline ListNode<RenameNode> * renames() const { return m_renames; }
		 /*! Sets undefines node
		 */
		 inline void setUndefines(ListNode<IdentifierNode> * u) { m_undefines=u; }
		 /*! Sets undefines node
		 */
		 inline void setRedefines(ListNode<IdentifierNode> * r) { m_redefines=r; }
		 /*! Sets rename node
		 */
		 inline void setRenames(ListNode<RenameNode> * r) { m_renames=r; }
		 /*! Sets select node
		 */
		 inline void setSelects(ListNode<IdentifierNode> * s) { m_selects=s; }
		 /*! Constructs a node from following data
			 \param[in] node node of name of class, that will be inherited
			 \param[in] inhtype string data
		 */
		 inline InheritanceNode(ClassTypeNode * node): 
		        AbstractNode(make_pos(node->line(),node->position()))
		 {
			 m_classname=node;
			 m_undefines=NULL;
			 m_redefines=NULL;
			 m_renames=NULL;
			 m_selects=NULL;
		 }
		 /*! Writes a node data to stream
		  */
		 void write(GraphStream * s);

		 inline ~InheritanceNode()
		 {
			 if (isOwningData())
			 {
				 delete m_classname;
				 delete m_undefines;
				 delete m_redefines;
				 delete m_renames;
				 delete m_selects;
			 }
		 }
};